/*
 * RemoteTurnSubStateController.h
 *
 *  Created on: Dec 30, 2011
 *      Author: rudi
 */

#ifndef REMOTETURNSUBSTATECONTROLLER_H_
#define REMOTETURNSUBSTATECONTROLLER_H_
#include <wx/wx.h>
#include "GameStartedSubStateController.h"
#include "DynamicDrawController.h"
#include "SmartPointer.h"

class IGameController;
class wxSocketEvent;

/**
 * This class handles the event when the turn is on the remote side
 *
 * During this period of the game, the application does not send any mouse related event to the remote side
 * @see IGameStateController
 * @author Rudolf Heszele heszele@gmail.com
 * @version 1.0
 * @since 2012-03-08
 */
class RemoteTurnSubStateController: public GameStartedSubStateController
{
	public:
		/**
		 * The default constructor is used when the game is started
		 *
		 * This constructor initializes all its data members by reading needed data from the configuration
		 */
		RemoteTurnSubStateController();
		/**
		 * This constructor is used to create the object after the game is started
		 *
		 * This constructor is needed to change the role of the application dynamically during the gameplay.
		 * In this case all the needed data is given to the constructor from the previous state, so the object
		 * can continue handling the events correctly
		 *
		 * @see DynamicDrawController
		 * @param level The bitmap of the level, to paint on
		 * @param originalLevel The original state of the level, used for repainting it during gameplay
		 * @param dynamicDrawController The used DynamicDrawController
		 */
		RemoteTurnSubStateController(SmartPointer<wxBitmap> level, SmartPointer<wxImage> originalLevel,
									 SmartPointer<DynamicDrawController> dynamicDrawController);
		virtual ~RemoteTurnSubStateController();

		// Methods inherited from Controller

		/**
		 * @see IController::handleMouseDown
		 */
		virtual void handleMouseDown(const wxPoint& position);
		/**
		 * @see IController::handleMouseUp
		 */
		virtual void handleMouseUp(const wxPoint& position);
		/**
		 * @see IController::handleMouseMotion
		 */
		virtual bool handleMouseMotion(const wxPoint& position);
		/**
		 * @see IController::getBitmapToPaint
		 */
		virtual const wxBitmap& getBitmapToPaint() const;
		/**
		 * @see IController::getBitmapToDraw
		 */
		virtual wxBitmap& getBitmapToDraw();

		// Methods inherited from GameStateController

		/**
		 * @see IGameStateContrller::handleSocketConnection
		 */
		virtual void handleSocketConnection(wxSocketEvent&);
		/**
		 * @see IGameStateContrller::handleSocketLost
		 */
		virtual void handleSocketLost(wxSocketEvent&);
		/**
		 * @see IGameStateContrller::handleSocketInput
		 */
		virtual void handleSocketInput(wxSocketEvent& socketEvent);
		/**
		 * @see IGameStateContrller::handleSocketOutput
		 */
		virtual void handleSocketOutput(wxSocketEvent&);

		// Methods inherited from GameStartedSubStateController

		/**
		 * @see GameStartedSubStateController::getSubstateId
		 */
		virtual SubstateId getSubstateId();
		/**
		 * @see GameStartedSubStateController::getNextSubStateController
		 */
		virtual GameStartedSubStateController* getNextSubStateController();

	private:
		SmartPointer<wxBitmap> mLevel;
		SmartPointer<wxImage> mOriginalLevel;
		SmartPointer<DynamicDrawController> mDynamicDrawController;
		bool mIsDataReceived;
};


#endif /* REMOTETURNSUBSTATECONTROLLER_H_ */
